home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src / lib / c / intuievent.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-04  |  2.5 KB  |  110 lines

  1. /*
  2. ** ACE linked library module: Intuition event trapping functions.
  3. ** Copyright (C) 1998 David Benn
  4. ** 
  5. ** This program is free software; you can redistribute it and/or
  6. ** modify it under the terms of the GNU General Public License
  7. ** as published by the Free Software Foundation; either version 2
  8. ** of the License, or (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program; if not, write to the Free Software
  17. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. **
  19. ** The purpose of the functions in this module is to centralise
  20. ** Intuition message handling for use by ACE event trapping code.
  21. ** 
  22. ** This amounts to putting a layer between raw Intuition message 
  23. ** handling functions (GetMsg() and ReplyMsg()) and ACE.
  24. **
  25. ** Author: David J Benn
  26. **   Date: 12th,17th,18th,24th,26th July 1994
  27. */
  28.  
  29. #include <intuition/intuition.h>
  30.  
  31. /* types */
  32. typedef    struct IntuiInfoStruct {
  33.     ULONG     Class;
  34.     USHORT     Code;
  35.     USHORT    GadgetID;
  36. } IntuiInfo;
  37.  
  38. /* globals */
  39. static     IntuiInfo IntuiEvent;
  40. static     IntuiInfo *the_event = NULL;
  41.  
  42. /* functions */
  43. IntuiInfo *GetIntuiEvent(UserPort)
  44. struct    MsgPort *UserPort;
  45. {
  46. struct     IntuiMessage *msg;
  47. struct    Gadget *GadPtr;
  48. /*
  49. ** Return latest relevant Intuition message info'.
  50. */
  51.     /* 
  52.     ** Attempt to retrieve a message from the IDCMP.
  53.     */
  54.     msg = (struct IntuiMessage *)GetMsg(UserPort); 
  55.     
  56.     /*
  57.     ** If not NULL, determine nature of message and obtain
  58.     ** appropriate information, ignoring IntuiTicks.
  59.     */ 
  60.     if (msg != NULL)
  61.     {
  62.         if (msg->Class != INTUITICKS)
  63.         {
  64.             /*
  65.             ** Fill IntuiInfo structure.
  66.             */    
  67.             IntuiEvent.Class = msg->Class;
  68.  
  69.             if (msg->Class & GADGETUP)
  70.             {
  71.                 /*
  72.                 ** Info' for gadget events. 
  73.                 */
  74.                 GadPtr = (struct Gadget *)msg->IAddress;
  75.                 IntuiEvent.GadgetID = GadPtr->GadgetID; 
  76.             }
  77.             else        
  78.                 /*
  79.                 ** Info' for all other events.
  80.                 */
  81.                 IntuiEvent.Code = msg->Code;
  82.             
  83.             /*
  84.             ** Point to the info'. 
  85.             */
  86.             the_event = &IntuiEvent;            
  87.         }    
  88.  
  89.         /*
  90.         ** Make sure we reply to each message once 
  91.         ** and _only_ once.
  92.         */
  93.         ReplyMsg(msg);
  94.     }
  95.  
  96.     /*
  97.     ** Return whatever message we now have (may be NULL).
  98.     */
  99.     return(the_event);
  100. }
  101.  
  102. void    ClearIntuiEvent()
  103. {
  104. /*
  105. ** If IntuiEvent has been matched by an event
  106. ** trapping test routine, make the_event NULL.
  107. */
  108.     the_event = NULL;
  109. }
  110.